home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / edit / aurora2.zip / DELDUP.AML < prev    next >
Text File  |  1995-01-26  |  2KB  |  68 lines

  1.  
  2. // ───────────────────────────────────────────────────────────────────
  3. // The Aurora Editor v2.0
  4. // Copyright 1993-1995 nuText Systems. All Rights Reserved Worldwide.
  5. //
  6. // Delete duplicate lines
  7. //
  8. // This macro deletes contiguous duplicate lines in the current edit
  9. // window. The total number of lines removed is displayed.
  10. //
  11. // (Note: this macro will run faster if undo is disabled)
  12. // ───────────────────────────────────────────────────────────────────
  13.  
  14.   include bootpath "define.aml"
  15.  
  16.   var lastline
  17.   var shownext
  18.  
  19.   // test for edit windows
  20.   if not wintype? "edit" then
  21.     msgbox "Edit windows only!"
  22.     return
  23.   end
  24.  
  25.   oldsize = getlines          // save the number of lines in file
  26.   undobegin                   // group this together as one undoable action
  27.   row 1                       // goto the first line
  28.   lasttext = gettext          // get first line in variable lasttext
  29.  
  30.   if down then                // goto the next line
  31.  
  32.     // do for all lines
  33.     loop
  34.  
  35.       // show progress every 150 lines
  36.       if getrow > shownext then
  37.         say (getrow)
  38.         shownext = shownext + 150
  39.       end
  40.  
  41.       // if this line is the same as the last line then delete it
  42.       if gettext == lasttext then
  43.  
  44.         // delete line and test for end-of-file
  45.         if delline > getrow then
  46.           break
  47.         end
  48.  
  49.       // ..otherwise save line text for the next comparision
  50.       // and goto the next line
  51.       else
  52.         lasttext = gettext
  53.         if not down then
  54.           break
  55.         end
  56.       end
  57.  
  58.     end
  59.  
  60.   end
  61.  
  62.   undoend                       // end of undoable group
  63.   display                       // update display
  64.  
  65.   // tell the user how many lines were removed
  66.   say  (thousands oldsize - getlines) + " lines were removed"
  67.  
  68.